/**
 * 
 */
package com.kelaite.procurement.constants;

import com.kelaite.procurement.exception.BusinessException;

/**
 * @author yuanchangwei
 *
 */
public enum CurrencyTypeEnum {

	CNY(0, "CNY", "￥"), USD(1, "USD", "$");

	private int val;

	private String desc;

	private String symbol;

	public int getVal() {

		return val;
	}

	public void setVal(int val) {

		this.val = val;
	}

	public String getDesc() {

		return desc;
	}

	public void setDesc(String desc) {

		this.desc = desc;
	}

	public String getSymbol() {

		return symbol;
	}

	public void setSymbol(String symbol) {

		this.symbol = symbol;
	}

	private CurrencyTypeEnum(int val, String desc, String symbol) {

		this.val = val;
		this.desc = desc;
		this.symbol = symbol;
	}

	public static CurrencyTypeEnum getCurrency(int input) {

		for (CurrencyTypeEnum entity : values()) {
			if (input == entity.getVal()) {
				return entity;
			}
		}
		throw new BusinessException(String.format("currency[%s] is illegal. ",
				input));
	}
}
